import Vue from 'vue'
import Router from 'vue-router'
const _import = require('./_import_' + process.env.NODE_ENV)
import layout from '../views/layout/main'

Vue.use(Router)

export const ConstRouterMap = [
  {
    path:'/login',
    component:_import('login/index'),
    hidden:true
  },
  {
    path: '/',
    component: layout,
    redirect: 'dashboard',
    hidden:true,
    children: [{
      path: 'dashboard',
      component: _import('dashboard/index'),
      name: 'dashboard',
      meta: { title: '首页', icon: 'dashboard', noCache: true }
    }]
  },
]

export default new Router({
  mode:'history',
  base:'school',
  scrollBehavior: () => ({
    y: 0
  }),
  routes: ConstRouterMap
})

/**
* hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
* redirect: noredirect           if `redirect:noredirect` will no redirct in the breadcrumb
* name:'router-name'             the name is used by <keep-alive> (must set!!!)
* meta : {
    role: ['admin','editor']     will control the page role (you can set multiple roles)
    title: 'title'               the name show in submenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar,
    noCache: true                if fasle ,the page will no be cached(default is false)
  }
**/
export const AsyncRouterMap = [
  {
    path:'/studentManage',
    component:layout,
    redirect:'/studentManage/index',
    name:'studentManage',
    meta: {
      title:'学生管理',
      icon: 'fa fa-user-circle fa-lg'
    },
    children:[
      {
        path:'index',
        name:'studentManage',
        component:_import('studentManage/index'),
        meta:{
          role:['admin'],
          title:'学生检索',
        }
      },
      {
        path:'add',
        name:'addStudent',
        component:_import('studentManage/addStudent'),
        meta:{
          role:['admin'],
          title:'添加学生'
        }
      },
      {
        path:'edit',
        name:'editStudent',
        hidden:true,
        component:_import('studentManage/editStudent'),
        meta:{
          role:['admin'],
          title:'编辑学生',
          hide:true
        }
      }
    ]
  },
  {
    path:'/tableManage',
    component:layout,
    redirect:'/tableManage/index',
    name:'模版页',
    meta: {
      title: 'Template',
      icon: 'fa fa-fire fa-lg'
    },
    children:[
      {
        path:'index',
        name:'操作模版',
        component:_import('Table/index'),
        meta: {
          role:['admin'],
          title:'操作模版',
        }
      },
      {
        path:'chart',
        name:'图表模版',
        component:_import('Chart/index'),
        meta: {
          role:['admin'],
          title:'图表模版',
          icon:"fa fa-bar-chart fa-lg"
        }
      }
    ]
  },
  {
    path:'/editor',
    name:'编辑器',
    redirect:'/editor/index',
    component:layout,
    noredirect:true,
    children:[
      {
        path:'index',
        name:'编辑器Demo',
        component:_import('editorDemo/index'),
        meta: {
          role:['admin'],
          title:'富文本编辑器',
          icon:"fa fa-edit fa-lg"
        }
      }
    ]
  }
]